#!/usr/bin/python
# -*- coding:utf-8 -*-
import maya.cmds as mc
import maya.mel as mel
import re

class Strings():
    "self string class"
    
    def pluginName(self,plugin):
        "get plugin name of current maya version"
        if mc.about(is64=1):
            x86x64 = "x64"
        else:
            x86x64 = "x86"
        mayaVersion = mc.about(f=1)
        pluginName = "%s%s%s.mll"%(plugin,mayaVersion,x86x64)
        return pluginName
        
    def changListToStr(self,list_):
        result = ''
        if type(list_)==list and len(list_)>=1:
            for i in range(len(list_)):
                if i== len(list_)-1:
                    result += '%s'%(list_[i])
                else:
                    result += '%s;'%(list_[i])
        elif list_==None or list_==[]:
            result = ''
        return result
        
    def changeStrToList(self,string,type2='str'):#three type change str in float
        result = None
        if string == '':
            result = []
        elif re.search(';',string) == None and type2=='str':
            result = [string]
        elif re.search(';',string) == None and type2=='int':
            result = [int(string)]
        elif re.search(';',string) == None and type2=='float':
            result = [float(string)]
        else:
            tempList = re.split(';',re.sub('\n','',string))
            result = []
            if type2 == 'str':
                result = tempList
            elif type2 == 'int':
                for x in tempList:
                    result.append(int(x))
            elif type2 == 'float':
                for x in tempList:
                    result.append(float(x))
        return result
        
StringsCls = Strings()